<template>
	<view>
		<view class="item-b">
			<view class="itembox" v-for="(item,index) in tablist" :key="index" @click="hahclass(item,index)">
				<view :class="['itembox', { selected: selectedIndices1 == index ? 'selected':''}]">
					<view class="nametxt">
						{{item.name}}
					</view>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data( ) {
			return {
				selectedIndices1: 0,
				tablist: [ {
						name: '全部'
					},
					{
						name: '出售中'
					},
					{
						name: '已下架'
					},
					{
						name: '已售罄'
					},
				],
			};
		},
		methods: {
			hahclass( item, index ) {
				this.selectedIndices1 = index
			},
		},
	}
</script>

<style lang="scss">
	.item-b {
		width: 750rpx;
		height: 76rpx;
		background-color: #fff;
		display: flex;
		align-items: center;

		.itembox {
			width: 114rpx;
			height: 76rpx;
			display: flex;
			align-items: center;
			margin-right: 2rpx;
			color: #666666;
			margin-right: 20rpx;

			.selected {
				/* 选中时的样式，比如背景色为红色 */
				color: #000000;
				border-bottom: 2rpx solid #247EFF;
			}

			.nametxt {
				width: 100%;
				height: 36rpx;
				font-weight: bold;
				font-size: 26rpx;
				color: #020001;
				text-align: center;
				margin-top: 20rpx;
			}
		}
	}
	
</style>